package Dao;

import DataClass.PartTimeTeacher;
import Util.JBDCUtil;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class PartTimeTeacherDao {

    private static PreparedStatement preparedStatement = null;

    public static List<PartTimeTeacher> getPartTimeTeacher() throws SQLException {
        List<PartTimeTeacher> list = new ArrayList<PartTimeTeacher>();

        ResultSet data = PartTimeTeacherDao.getDataPartTimeTeacher();

        while(data.next()){
            String TCName = data.getString("TCName");
            String JTNo = data.getString("JTNo");
            String TProfessionalAffiliations = data.getString("TProfessionalAffiliations");
            list.add(new PartTimeTeacher(TCName,JTNo,TProfessionalAffiliations));
        }
        return list;
    }

    public static ResultSet getDataPartTimeTeacher() throws SQLException {
        if(preparedStatement == null)
        {
            String sql = "select * from Teacher where TTno = '校内院聘非事业编全职教师'";
            preparedStatement = JBDCUtil.getPreparedStatement(sql);
        }
        ResultSet data = preparedStatement.executeQuery();
        JBDCUtil.commit();
        return data;
    }
}
